From 443933fef5fc57b04d1f453158933ac96af57748 Mon Sep 17 00:00:00 2001 From: Ariel Glenn Date: Thu, 15 Sep 2011 17:18:13 +0000 Subject: [PATCH] throw exception if rename of output file fails --- includes/Export.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/includes/Export.php b/includes/Export.php index ac28a54163..2b1a000519 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -759,8 +759,10 @@ class DumpFileOutput extends DumpOutput { } if ( $newname ) { fclose( $this->handle ); - rename( $this->filename, $newname ); - if ( $open ) { + if (! rename( $this->filename, $newname ) ) { + throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" ); + } + elseif ( $open ) { $this->handle = fopen( $this->filename, "wt" ); } } @@ -814,8 +816,10 @@ class DumpPipeOutput extends DumpFileOutput { if ( $newname ) { fclose( $this->handle ); proc_close( $this->procOpenResource ); - rename( $this->filename, $newname ); - if ( $open ) { + if (! rename( $this->filename, $newname ) ) { + throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" ); + } + elseif ( $open ) { $command = $this->command; $command .= " > " . wfEscapeShellArg( $this->filename ); $this->startCommand( $command ); @@ -873,8 +877,10 @@ class Dump7ZipOutput extends DumpPipeOutput { if ( $newname ) { fclose( $this->handle ); proc_close( $this->procOpenResource ); - rename( $this->filename, $newname ); - if ( $open ) { + if (! rename( $this->filename, $newname ) ) { + throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" ); + } + elseif ( $open ) { $command = "7za a -bd -si " . wfEscapeShellArg( $file ); // Suppress annoying useless crap from p7zip // Unfortunately this could suppress real error messages too -- 2.20.1